import 'package:kepu/generated/json/base/json_convert_content.dart';
import 'package:kepu/model/animal_list_entity.dart';

AnimalListEntity $AnimalListEntityFromJson(Map<String, dynamic> json) {
  final AnimalListEntity animalListEntity = AnimalListEntity();
  final int? code = jsonConvert.convert<int>(json['code']);
  if (code != null) {
    animalListEntity.code = code;
  }
  final String? msg = jsonConvert.convert<String>(json['msg']);
  if (msg != null) {
    animalListEntity.msg = msg;
  }
  final AnimalListData? data = jsonConvert.convert<AnimalListData>(
      json['data']);
  if (data != null) {
    animalListEntity.data = data;
  }
  return animalListEntity;
}

Map<String, dynamic> $AnimalListEntityToJson(AnimalListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['code'] = entity.code;
  data['msg'] = entity.msg;
  data['data'] = entity.data.toJson();
  return data;
}

extension AnimalListEntityExtension on AnimalListEntity {
  AnimalListEntity copyWith({
    int? code,
    String? msg,
    AnimalListData? data,
  }) {
    return AnimalListEntity()
      ..code = code ?? this.code
      ..msg = msg ?? this.msg
      ..data = data ?? this.data;
  }
}

AnimalListData $AnimalListDataFromJson(Map<String, dynamic> json) {
  final AnimalListData animalListData = AnimalListData();
  final List<AnimalListDataRecords>? records = (json['records'] as List<
      dynamic>?)
      ?.map(
          (e) =>
      jsonConvert.convert<AnimalListDataRecords>(e) as AnimalListDataRecords)
      .toList();
  if (records != null) {
    animalListData.records = records;
  }
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    animalListData.total = total;
  }
  final int? size = jsonConvert.convert<int>(json['size']);
  if (size != null) {
    animalListData.size = size;
  }
  final int? current = jsonConvert.convert<int>(json['current']);
  if (current != null) {
    animalListData.current = current;
  }
  final int? pages = jsonConvert.convert<int>(json['pages']);
  if (pages != null) {
    animalListData.pages = pages;
  }
  return animalListData;
}

Map<String, dynamic> $AnimalListDataToJson(AnimalListData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['records'] = entity.records.map((v) => v.toJson()).toList();
  data['total'] = entity.total;
  data['size'] = entity.size;
  data['current'] = entity.current;
  data['pages'] = entity.pages;
  return data;
}

extension AnimalListDataExtension on AnimalListData {
  AnimalListData copyWith({
    List<AnimalListDataRecords>? records,
    int? total,
    int? size,
    int? current,
    int? pages,
  }) {
    return AnimalListData()
      ..records = records ?? this.records
      ..total = total ?? this.total
      ..size = size ?? this.size
      ..current = current ?? this.current
      ..pages = pages ?? this.pages;
  }
}

AnimalListDataRecords $AnimalListDataRecordsFromJson(
    Map<String, dynamic> json) {
  final AnimalListDataRecords animalListDataRecords = AnimalListDataRecords();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    animalListDataRecords.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    animalListDataRecords.name = name;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    animalListDataRecords.image = image;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    animalListDataRecords.description = description;
  }
  final String? region = jsonConvert.convert<String>(json['region']);
  if (region != null) {
    animalListDataRecords.region = region;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    animalListDataRecords.type = type;
  }
  return animalListDataRecords;
}

Map<String, dynamic> $AnimalListDataRecordsToJson(
    AnimalListDataRecords entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['image'] = entity.image;
  data['description'] = entity.description;
  data['region'] = entity.region;
  data['type'] = entity.type;
  return data;
}

extension AnimalListDataRecordsExtension on AnimalListDataRecords {
  AnimalListDataRecords copyWith({
    int? id,
    String? name,
    String? image,
    String? description,
    String? region,
    String? type,
  }) {
    return AnimalListDataRecords()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..image = image ?? this.image
      ..description = description ?? this.description
      ..region = region ?? this.region
      ..type = type ?? this.type;
  }
}